package com.jt.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

@Component
public class ConnectionUtil {
    public  static Connection getConnection() throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        factory.setUsername("guest");
        factory.setPort(5672);
        factory.setPassword("guest");
        /*获取连接*/
        Connection connection = factory.newConnection();
        System.out.println(connection);
        return connection;
    }

}
